// Package day_01_base_sort insert_sort
// @Title day_01_base_sort
// @Description
// @Author  == 琳琳也叫王木木 ==  2021/8/30 17:01
// @Create  2021/8/30 17:01
package day_01_base_sort

// InsertSort 插入排序
func InsertSort(nums []int) []int {
	arrLen := len(nums)
	if arrLen < 2 || nums == nil {
		return nums
	}
	for i := 1; i < len(nums); i++ {
		for j := i - 1; j >= 0 && nums[j] > nums[j+1]; j-- {
			nums[j], nums[j+1] = nums[j+1], nums[j]
		}
	}
	return nums
}
